package team.hyznrj.studentsys.entity;

import java.util.HashMap;
import java.util.Map;

import com.mongodb.BasicDBObject;

import team.hyznrj.studentsys.exception.DataNullException;
import team.hyznrj.studentsys.service.impl.StaticDatabasesValueCache;

public class QualityOutputTable {
	Map<String,QualityStudent> map=new HashMap<>();
	public Map<String,QualityStudent> getObject(){
		return map;
	}
	/**
	 * 导入操行分信息
	 * @param obj  导入对象
	 * @param cache 动态的数据缓存
	 */
	public void put(QualityAchievement obj,StaticDatabasesValueCache cache){
		if(obj==null||cache==null){
			return ;
		}
		String sno = obj.getSno();
		QualityStudent stu=null;
		if(map.containsKey(sno)){
			stu=map.get(sno);
		}else{
			throw new DataNullException("学生信息缺失,操行分汇总失败");
		}
		String key=cache.getQualitiyTypeById(obj.getProjectType())+"#"+
		cache.getYearById(obj.getAcademicYears())+"#"+obj.getItem()+"#"+obj.getProject();
		System.out.println("put ->"+key);
		stu.put(key,obj);
	}
	/***
	 * 导入学生信息
	 * @param obj
	 * @param idMap
	 */
	public void put(BasicDBObject obj,Map<String, String> idMap){
		String sno = obj.getString(idMap.get("学号"));
		if(!map.containsKey(sno)){
			QualityStudent stu=new QualityStudent();
			stu.setStudentBasicMessageValue(obj, idMap);
			map.put(sno, stu);
		}
	}
	@Override
	public String toString() {
		return "QualityOutputTable [map=" + map + "]";
	}
}
